<script setup lang="ts">
const props = defineProps({
  images: {
    type: String,
  },
});
const previewShow = ref(false);
const previewImages = ref<string[]>([]);
const onImageClick = () => {
  previewImages.value = props.images?.split(',') || [];
  previewShow.value = true;
};
</script>

<template>
  <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
    <van-swipe-item v-for="(img, index) in images?.split(',')" :key="index">
      <van-image @click="onImageClick" fit="fill" :src="img" />
    </van-swipe-item>
  </van-swipe>
  <van-image-preview v-model:show="previewShow" :images="previewImages"></van-image-preview>
</template>

<style scoped lang="scss">
.my-swipe .van-swipe-item {
  width: 100%;
  height: 375px;

  .van-image {
    width: 100%;
    height: 100%;
  }
}
</style>
